import path from "path";

import { createDefineMock } from "vite-plugin-mock-dev-server";

const defineMock = createDefineMock((mock) => {
  mock.url = path.join(import.meta.env.VITE_APP_BASE_API, mock.url);
});

const list = [
  {
    createBy: "admin",
    createTime: "2023-04-23 16:13:51",
    updateBy: "",
    updateTime: null,
    remark: "管理员",
    noticeId: 1,
    noticeTitle: "温馨提醒：2018-07-01 若依新版本发布啦",
    noticeType: "2",
    noticeContent: "新版本内容",
    status: "0",
  },
  {
    createBy: "admin",
    createTime: "2023-04-23 16:13:51",
    updateBy: "",
    updateTime: null,
    remark: "管理员",
    noticeId: 2,
    noticeTitle: "维护通知：2018-07-01 若依系统凌晨维护",
    noticeType: "1",
    noticeContent: "维护内容",
    status: "0",
  },
];

export default defineMock([
  {
    url: "/api/notice/list",
    method: ["GET"],
    body: ({ query }) => {
      console.log("notice", query);
      return {
        code: 200,
        msg: "success",
        data: {
          list: list,
          total: list.length,
        },
      };
    },
  },
]);
